<?php
include("./include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  header('location:checkLogin.php');
}

$today = date("d/m/y");
$sellId = $_REQUEST['sellId'];

//Submit Sell Item Detail
if(isset($_REQUEST['submitBtn']))
{
  $amount    = $_REQUEST['amount'];
  $narration = $_REQUEST['narration'];
  $date      = $_REQUEST['curDateYear']."-".$_REQUEST['curDateMonth']."-".$_REQUEST['curDateDay'];
  
  //Update Sell Item Detail
  $insertSellItem = "UPDATE loan 
                        SET soldAmount    = '".$amount."', 
                            soldDate      = '".$date."', 
                            isSold        = 'Y',
                            soldNarration = '".$narration."'
                      WHERE loanId = ".$sellId;
  $sellItemResult = mysql_query($insertSellItem);
  header("location:soldItem.php");
}

include("./bottom.php");
$smarty->assign("today",$today);
$smarty->display('sellItemDetail.tpl');
?>